<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="application/msword; charset=utf-8"/>
    <title>toWord</title>
    <style type="text/css">
        /*table start*/
        table.default-table {
            /* -moz-border-radius: 5px; -webkit-border-radius:5px; border-radius:5px; */
            width: 100%;
            border: solid #333;
            border-width: 1px 0px 0px 1px;
            font-size: 14PX;
            border-collapse: collapse;
            border-spacing: 0;
        }

        table.default-table tbody tr {
            height: 20px;
            line-height: 20px;
        }

        table.default-table tbody tr.odd {
            background-color: #fff;
        }

        table.default-table tbody tr.even {
            background-color: #F5F5F5;
        }

        table.default-table tbody tr:hover {
            background-color: #eee;
        }

        table.default-table tbody tr th, table.default-table tbody tr td {
            padding: 3px 5px;
            text-align: left;
            /* border: 1px solid #ddd; */
            border: solid #333;
            border-width: 0px 1px 1px 0px;
        }

        table.default-table tbody tr th {
            font-weight: bold;
            text-align: center;
        }

        table.default-table tbody tr td.tac {
            text-align: center;
        }

        table.default-table tbody tr td a:hover {
            color: #0080c0;
        }

        .textarea-style {
            font-size: 14px;
            font-weight: bold;
            color: #000;
            background-color: #d7d7d7;
            width: 100%;
            border: solid #333;
            border-width: 1px 0px 0px 1px;
        }

        .bg {
            font-size: 14px;
            font-weight: bold;
            color: #000;
            background-color: #d7d7d7;
        }

        tr {
            height: 32px;
            font-size: 12px;
        }

        td {
            padding-left: 10px;
            border-width: 1px;
            border-style: solid;
            border-color: black;
            height: 32px;
            overflow: hidden;
            word-break: break-all;
            word-wrap: break-word;
            font-size: 14px;
        }

        .bg td {
            font-size: 14px;
        }

        tr td {
            font-size: 14px;
        }

        .specialHeight {
            height: 40px;
        }

        .first_title {
            height: 60px;
            line-height: 60px;
            margin: 0;
            font-weight: bold;
            font-size: 21px;
        }

        .second_title {
            height: 40px;
            line-height: 40px;
            margin: 0;
            font-size: 18px;
        }

        .third_title {
            height: 40px;
            line-height: 40px;
            margin: 0;
            font-size: 16px;
        }

        .doc_title {
            font-size: 42px;
            text-align: center;
        }

        .download_btn {
            float: right;
        }

        .mystyle {
            border-top: none;
            border-left: none;
            border-bottom: solid #CCCCCC 1.0pt;
            border-right: solid #CCCCCC 1.0pt;
            padding: 4.5pt 9.0pt 4.5pt 9.0pt
        }

        body {
            font-family: 思源黑体 Normal;
        }
    </style>
</head>
<body>
<div style="width:1000px; margin: 0 auto">
    <div>
        <p class="doc_title" th:text="${info.title}"></p>
        <a class="download_btn" th:if="${download == 1}" th:href="${'/tool/swagger/downloadWord?swaggerId='+ swagger.swaggerId}">下载文档</a>
        <br>
    </div>
    <div th:each="tableMap:${tableMap}" style="margin-bottom:20px;">
        <!--这个是类的说明-->
        <h4 class="first_title" th:text="${tableMapStat.count} + '. ' + ${tableMap.key}"></h4>

        <div th:each="table,tableStat:${tableMap.value}">

            <!--这个是每个请求的说明，方便生成文档后进行整理-->
            <h5 class="second_title"
                th:text="${tableMapStat.count} + '.' + ${tableStat.count} + '. '+ ${tableMap.key} + '-' + ${table.tag}"></h5>
            <h6 class="third_title" th:text="${tableMapStat.count} + '.' + ${tableStat.count} + '.1. ' + 接口："></h6>

            <table class="default-table" width="100%">
                <tr>
                    <td class="tac" width="15%">接口描述</td>
                    <td class="tac" colspan="4" th:text="${table.description}"></td>
                </tr>
                <tr>
                    <td class="tac">请求地址</td>
                    <td class="tac" colspan="4" th:text="${table.url}"></td>
                </tr>
                <tr>
                    <td class="tac">请求方式</td>
                    <td class="tac" colspan="4" th:text="${table.requestType}"></td>
                </tr>
                <tr>
                    <td class="tac">返回格式</td>
                    <td class="tac" colspan="4" th:text="'application/json;charset=UTF-8'"></td>
                </tr>

            </table>
            <!--这个是每个请求的说明，方便生成文档后进行整理-->
            <h6 class="third_title" th:text="${tableMapStat.count} + '.' +  ${tableStat.count} + '.2  ' + 请求参数"></h6>

            <table class="default-table" width="100%">

                <tr class="bg">
                    <td class="tac" width="15%">参数名</td>
                    <td class="tac" width="15%">数据类型</td>
                    <td class="tac" width="15%">参数类型</td>
                    <td class="tac" width="15%">是否必填</td>
                    <td class="tac">说明</td>
                </tr>

                <th:block th:each="request, c:${table.requestList}">
                    <tr th:if="${table.requestType} == 'GET'">
                        <td align="left" th:text="${request.name}"></td>
                        <td th:text="${request.type}"></td>
                        <td th:text="${request.paramType}"></td>
                        <td th:if="${request.require}" th:text="Y"></td>
                        <td th:if="${!request.require}" th:text="N"></td>
                        <td th:text="${request.remark}"></td>
                    </tr>

                    <th:block th:if="${request.modelAttr}">
                        <tbody th:include="this::request(${request.modelAttr.properties},${c.count} + '.', 1)"/>
                    </th:block>

                <tr class="bg">
                    <td>状态码</td>
                    <td colspan="2">描述</td>
                    <td colspan="2">说明</td>
                </tr>

                <tr th:each="response:${table.responseList}">
                    <td th:text="${response.name}"></td>
                    <td colspan="2" th:text="${response.description}"></td>
                    <td colspan="2" th:text="${response.remark}"></td>
                </tr>

                <tr class="bg">
                    <td>返回属性名</td>
                    <td colspan="2">类型</td>
                    <td colspan="2">说明</td>
                </tr>

<!--               对返回参数 递归生成行-->
                <tbody th:include="this::response(${table.modelAttr.properties},'', 1)"/>

                <tr class="bg">
                    <td colspan="5">示例</td>
                </tr>
                <tr class="specialHeight">
                    <td class="bg">请求参数</td>
                    <td colspan="4" th:text="${table.requestParam}"></td>
                </tr>
                <tr class="specialHeight">
                    <td class="bg">返回值</td>
                    <td colspan="4" th:text="${table.responseParam}"></td>
                </tr>

            </table>
        </div>
    </div>
</div>

<th:block th:fragment="request(properties,count, lv)">
    <th:block th:each="p,c : ${properties}">
        <tr>
            <td align="left" th:text="${count} + '' + ${c.count} + '.' + ${p.name}"
                th:style="|padding-left:${10*lv}px|"></td>
            <td th:text="${p.type}"></td>
            <td></td>
            <td th:if="${p.require}" th:text="Y"></td>
            <td th:if="${!p.require}" th:text="N"></td>
            <td th:text="${p.description}"></td>
        </tr>
        <th:block th:unless="${#lists.isEmpty(p.properties)}"
                  th:include="this::request(${p.properties},${count} + '' + ${c.count} + '.',${lv+1})"/>
    </th:block>
</th:block>

<th:block th:fragment="response(properties,count, lv)">
    <th:block th:each="p,c : ${properties}">
        <tr>
            <td align="left" th:text="${count} + '' + ${c.count} + '.' + ${p.name}"
                th:style="|padding-left:${10*lv}px|"></td>
            <td colspan="2" th:text="${p.type}"></td>
            <td colspan="2" th:text="${p.description}"></td>
        </tr>
        <th:block th:unless="${#lists.isEmpty(p.properties)}"
                  th:include="this::response(${p.properties},${count} + '' + ${c.count} + '.',${lv+1})"/>
    </th:block>
</th:block>
</body>
</html>
